<tr>
    <td>
	<table width="100%"  border="0" cellpadding="10" cellspacing="2">
      <tr bgcolor="#009999">
        <td colspan="3">Suporte IT  | Estado de Tickets</td>
      </tr>
      <tr>
        <td width="20%" rowspan="3" valign="top" bgcolor="#F2F2F2"></p></td>
        <td colspan="2" bgcolor="#F2F2F2">
	<table width="100%" border="0" cellpadding="4" cellspacing="1">
		<?php 
				$CTickets = "SELECT 
							it_tickets.ref,
							it_tickets.main_users_ref AS UsersRef,
							 it_tickets.time_creation,
							  it_tickets.Description,
							   it_tickets.refUserAtrib,
							    it_tickets.status,
							    it_tickets.time_solve,
								it_status.name AS Status,
								 main_users.ref AS MainUsersRef,
								 main_users.name AS UserName
								FROM it_tickets 
								INNER JOIN main_users ON main_users.ref = it_tickets.main_users_ref
								INNER JOIN it_status ON it_status.ref = it_tickets.status
								WHERE main_users_ref = '{$_SESSION['UtID']}'";
				$Tickets = $GLOBALS['CONN']->db_array($CTickets);
				for ($t = 1; $t <= $Tickets[0]; $t++) { ?>
      <tr bgcolor="#E0E1D5">
        <td width="30%"><a href="index.php?action=show&Ticket=<?php echo $Tickets[$t]['ref'];?>">Aberto a: <?php echo $Tickets[$t]['time_creation'];?></a></td>
        <td width="30%">Situação: <?php echo substr($Tickets[$t]['Description'],0,30);?></td>
        <td width="30%">Estado: <?php echo $Tickets[$t]['Status'];?></td>
      </tr>
	  <?php if (isset($_GET['Ticket']) && $_GET['Ticket'] == $Tickets[$t]['ref']) { ?>
	  <tr bgcolor="#FFFFFF">
	    <td colspan="2"><strong>Descrição</strong><br>
		<?php echo $Tickets[$t]['Description'];?></td>
	    <td><strong>Responsável</strong><br>
	      <?php
		  					$CAtribs = "SELECT ref,name
										FROM main_users
										WHERE ref = {$Tickets[$t]['refUserAtrib']}";
							$Atribs = $GLOBALS['CONN']->db_array($CAtribs);
		  					print $Atribs[1]['name'];?>	      </td>
	    </tr>
	<?php if ($Tickets[$t]['status'] == '3' || $Tickets[$t]['status'] == '5') { ?>
	  <tr bgcolor="#FFFFFF">
	    <td colspan="2"><strong>Resolução</strong><br>
		<?php echo $Tickets[$t]['Response'];?></td>
	    <td>Data de resolução<br>
	      <?php echo $Tickets[$t]['time_solve'];?></td>
	    </tr>

	  <?php }
	  }
	  } ?>
    </table>
	</td></tr>
    </table>
	</td>
  </tr>